<%@ page pageEncoding="utf-8" %>
<%@include file="/commons/taglibs.jsp" %>
<!DOCTYPE html>
<html>
<fmt:bundle basename="res">
<head>
    <meta charset="utf-8">
    <title><fmt:message key='ttblsjxt'/></title>
    <jsp:include page="/WEB-INF/commons/commons-header.jsp" flush="true"/>
    <style>
        html {
            background: #fff;
        }
    </style>
</head>

<body>
<div class="layui-container">
    <div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

        <form:form commandName="coupon" method="${_method }" class="layui-form" id="form">
            <input type="hidden" name="_method" value="${_method }"/>
            <form:hidden path="id"/>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='sjmc'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.merchant.shopName}
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='yhjlx'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:if test="${coupon.type eq 1}"><fmt:message key='mjj'/></c:if>
                    <c:if test="${coupon.type eq 2}"><fmt:message key='zpj'/></c:if>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='yhjfl'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:forEach items="${channels}" var="channel">
                        <c:if test="${fn:contains(channelNames, channel.name)}">${channel.name}</c:if>
                    </c:forEach>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='yhjmc'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.name}
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='mkje'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.conditionAmount}
                </div>
            </div>

            <div class="layui-form-item feijin-manjian-area" style="display:none;">
                <label class="layui-form-label"> <fmt:message key='yhjmz'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.denominationAmount}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"> <fmt:message key='ffsl'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.releasedQuantity}
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='yhjyxq'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:if test="${coupon.validityType eq 1}"><fmt:message key='gdrq'/></c:if>
                    <c:if test="${coupon.validityType eq 2}"><fmt:message key='lqhsy'/></c:if>
                </div>
            </div>

            <div class="layui-form-item feijin-validityType-gudin-area" style="display:none;">
                <label class="layui-form-label"></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.validityBeginDay} - ${coupon.validityEndDay}
                </div>
            </div>

            <div class="layui-form-item feijin-validityType-tianshu-area" style="display:none;">
                <label class="layui-form-label"></label>
                <div class="layui-form-mid layui-word-aux">
                    <fmt:message key='lqh'/>${coupon.validityDay}<fmt:message key='tnksy'/>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='sysp'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:if test="${coupon.scopeType eq 1}"><fmt:message key='sysp'/></c:if>
                    <c:if test="${coupon.scopeType eq 2}"><fmt:message key='zdsp'/></c:if>
                </div>
            </div>


            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='cjsj'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <fmt:formatDate value="${coupon.createTime}" type="both"/>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='sjzt'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${coupon.publishStatus eq 1}"><fmt:message key='sj'/></c:when>
                        <c:when test="${coupon.publishStatus eq 2}"><fmt:message key='xj'/></c:when>
                    </c:choose>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='shzt'/></label>
                <div class="layui-form-mid layui-word-aux">
                    <c:choose>
                        <c:when test="${coupon.status eq 1}"><fmt:message key='dsh'/></c:when>
                        <c:when test="${coupon.status eq 2}"><fmt:message key='shtg'/></c:when>
                        <c:when test="${coupon.status eq 3}"><fmt:message key='shbtg'/></c:when>
                        <c:when test="${coupon.status eq 4}"><fmt:message key='shz'/></c:when>
                    </c:choose>
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><fmt:message key='shbz'/></label>
                <div class="layui-form-mid layui-word-aux">
                        ${coupon.note}
                </div>
            </div>


            <div class="layui-form-item feijin-shiyong-area" style="display:none;">
                <label class="layui-form-label"></label>
                <div class="layui-input-block">
                    <table class="layui-table" lay-size="sm">
                        <thead>
                        <tr>
                            <th><fmt:message key='spbh'/></th>
                            <th><fmt:message key='spmc'/></th>
                            <th><fmt:message key='sptp'/></th>
                        </tr>
                        </thead>
                        <tbody id="feijin-chooseGoods-table">
                        <c:if test="${empty goodses}">
                            <tr>
                                <td colspan="4">
                                    <center><fmt:message key='zwsj'/></center>
                                </td>
                            </tr>
                        </c:if>
                        <c:forEach items="${goodses}" var="goods">
                            <tr>
                                <td>${goods.goods.goodsNo}</td>
                                <td>${goods.goods.name}</td>
                                <td><img class="preview" style="width:40px;height:40px;" src="${store_domain}/uploads/${goods.goods.defaultImage}"/></td>
                                    <%--<td>--%>
                                    <%--<div class="layui-btn-container">--%>
                                    <%--<a href="javascript:void(0);" data-id="${goods.id}" class="layui-btn layui-btn-xs  layui-btn-danger feijin-kezilai-remove">删除</a>--%>
                                    <%--</div>--%>
                                    <%--</td>--%>
                            </tr>
                        </c:forEach>
                        </tbody>

                    </table>

                </div>
            </div>

            <div class="layui-form-item feijin-zenpin-area" style="display:none;">
                <label class="layui-form-label"><fmt:message key='zp'/></label>
                <div class="layui-input-block">
                    <table class="layui-table" lay-size="sm" id="feijin-sku-table">
                        <thead>
                        <tr>
                            <th><fmt:message key='spbh'/></th>
                            <th><fmt:message key='spmc'/></th>
                            <th><fmt:message key='sptp'/></th>
                        </tr>
                        </thead>
                        <tbody id="feijin-complimentaryGoods-table">
                        <c:if test="${null == coupon.complimentaryGoods}">
                            <tr>
                                <td colspan="4">
                                    <center><fmt:message key='zwsj'/></center>
                                </td>
                            </tr>
                        </c:if>
                        <c:if test="${null != coupon.complimentaryGoods}">
                            <tr>
                                <td>${coupon.complimentaryGoods.goodsNo}</td>
                                <td>${coupon.complimentaryGoods.name}</td>
                                <td><img class="preview" style="width:40px;height:40px;" src="${store_domain}/uploads/${coupon.complimentaryGoods.defaultImage}"/></td>
                            </tr>
                        </c:if>
                        </tbody>

                    </table>

                </div>
            </div>


            <div class="layui-input-block">
                <div style="display: none">
                    <input type="hidden" name="channelData" id="channelData"/>
                    <input type="hidden" name="goodsesData" id="goodsesData" value="<c:forEach items="${goodses}" var="goods">${goods.goods.id}-</c:forEach>"/>
                    <input type="button" value="<fmt:message key='bc'/>" class="layui-btn" id="submit" lay-filter="submit" lay-submit>
                </div>
            </div>

        </form:form>
    </div>
</div>
<script>
    $(function () {

        var scopeType = "${coupon.scopeType}";
        if (scopeType == 1) {
            $(".feijin-shiyong-area").hide();
        }
        if (scopeType == 2) {
            $(".feijin-shiyong-area").show();
        }

        var validityType = "${coupon.validityType}";
        if (validityType == 1) {
            $(".feijin-validityType-gudin-area").show();
            $(".feijin-validityType-tianshu-area").hide();
        }
        if (validityType == 2) {
            $(".feijin-validityType-gudin-area").hide();
            $(".feijin-validityType-tianshu-area").show();
        }


        var type = "${coupon.type}";
        if (type == 1) {
            $(".feijin-zenpin-area").hide();
            $(".feijin-manjian-area").show();
        }

        if (type == 2) {
            $(".feijin-zenpin-area").show();
            $(".feijin-manjian-area").hide();
        }

    });
</script>
</body>
</fmt:bundle>
</html>